package cn.ac.big.bigd.dao;

import cn.ac.big.bigd.model.User;
import cn.ac.big.bigd.model.submit.Submission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *@Author wangfan
 *@Date 2016/11/29 15:49
 */
@Repository
public interface SubmissionDao extends JpaRepository<Submission, Long> {
    List<Submission> findBySubStatus(int subStatus);
    Submission findByMissionId(String missionId);
    List<Submission> findByUser(User user);
    List<Submission> findByUserAndIsDeleteNot(User user, boolean delete);
    @Query(value = "select max(mission_id) from submission order by  mission_id desc ", nativeQuery = true)
    String  findMaxByMissionIdDesc();

    @Query(value = "select min(accession) from submission order by  accession desc ", nativeQuery = true)
    String  findMinByAccessionDesc();
    @Query(value = "select max(accession) from submission order by  accession desc ", nativeQuery = true)
    String  findMaxByAccessionDesc();


    List<Submission> findByAccessionStartingWith(String accession);
    Submission  findByAccession(String accession);
}
